#pragma once
#include <utility>
#include <vector>
#include "enemy.h"
#include <ClanLib/core.h>
#include <stdlib.h>
#include "sound.h"

#ifndef __gameconstants
#include "gameconstants.h"
#define __gameconstants
#endif

#include "resourcemanager.h"

// sprunganimation
const int jumpAnimationCount = 61;
const float jumpAnimation[61] = { 0 * MOVING_SPEED, 11 * MOVING_SPEED, 14
		* MOVING_SPEED, 17 * MOVING_SPEED, 19 * MOVING_SPEED,
		20 * MOVING_SPEED, 22 * MOVING_SPEED, 23 * MOVING_SPEED, 24
				* MOVING_SPEED, 26 * MOVING_SPEED, 27 * MOVING_SPEED, 27
				* MOVING_SPEED, 28 * MOVING_SPEED, 29 * MOVING_SPEED, 30
				* MOVING_SPEED, 30 * MOVING_SPEED, 31 * MOVING_SPEED, 32
				* MOVING_SPEED, 32 * MOVING_SPEED, 33 * MOVING_SPEED, 33
				* MOVING_SPEED, 33 * MOVING_SPEED, 34 * MOVING_SPEED, 34
				* MOVING_SPEED, 34 * MOVING_SPEED, 35 * MOVING_SPEED, 35
				* MOVING_SPEED, 35 * MOVING_SPEED, 35 * MOVING_SPEED, 35
				* MOVING_SPEED, 35 * MOVING_SPEED, 35 * MOVING_SPEED, 35
				* MOVING_SPEED, 35 * MOVING_SPEED, 35 * MOVING_SPEED, 35
				* MOVING_SPEED, 34 * MOVING_SPEED, 34 * MOVING_SPEED, 34
				* MOVING_SPEED, 33 * MOVING_SPEED, 33 * MOVING_SPEED, 33
				* MOVING_SPEED, 32 * MOVING_SPEED, 32 * MOVING_SPEED, 31
				* MOVING_SPEED, 30 * MOVING_SPEED, 30 * MOVING_SPEED, 29
				* MOVING_SPEED, 28 * MOVING_SPEED, 27 * MOVING_SPEED, 27
				* MOVING_SPEED, 26 * MOVING_SPEED, 24 * MOVING_SPEED, 23
				* MOVING_SPEED, 22 * MOVING_SPEED, 20 * MOVING_SPEED, 19
				* MOVING_SPEED, 17 * MOVING_SPEED, 14 * MOVING_SPEED, 11
				* MOVING_SPEED, 0 * MOVING_SPEED };

class GameModel {
public:
	static GameModel* getInstance();
	GameState::GameState getGameState();

	bool isGameRunning;
	bool continueJump;
	bool fallDownActive;

	void addEnemy(Enemy* enemy);
	std::vector<Enemy*> getEnemies();

	void playerMoveLeft();
	void playerMoveRight();
	void playerJump();
	bool executePlayerJump();
	void fallDown();

private:

	GameModel(void);
	~GameModel(void);
	Sound* sound;
	static GameModel* instance;
	std::vector<Enemy*> enemies;
	bool hasKebab;
	int currentAnimationStep;

	void moveEnemies();
	void checkEnemyCollision();
	bool isBlockColliding(const char &block, const float collX,
			const float collY);
	bool checkCollision(enum CheckDirection::CheckDirection dir);
	void playerJumpDoNextAnimationStep();

	GameState::GameState gamestate;
	ResourceManager* resourceManager;
};
